/*
 * ListAst.cpp
 *
 *  Created on: 6 Dec 2010
 *      Author: kn308
 */

#include <MAlice/Ast/ListAst.h>

namespace MAlice
{

ListAst::ListAst() :
	mChildren()
{
}

ListAst::ListAst(Ast* child) :
	mChildren(1, child)
{
}

ListAst::ListAst(const vector<Ast*>& children) :
	mChildren(children)
{
}

ListAst::~ListAst()
{
	vector<Ast*>::iterator i = mChildren.begin();
	vector<Ast*>::iterator e = mChildren.end();
	for (; i != e; i++)
		delete *i;
}

llvm::Value* ListAst::generate()
{
#	ifndef NDEBUG
	cout << "ListAst::generate() : " << mChildren.size() << endl;
#	endif

	Value* value = NULL;
	vector<Ast*>::iterator i = mChildren.begin();
	vector<Ast*>::iterator e = mChildren.end();
	for (int index = 0; i != e; i++, index++)
	{
		value = (*i)->generate();
	}

	return value;
}

}
